package com.net.xpay.common.manager.impl;

import com.google.common.base.Preconditions;
import com.net.common.annotation.ReadTransactional;
import com.net.common.dao.BasicMapper;
import com.net.common.dao.Page;
import com.net.xpay.common.dao.LoginLogMapper;
import com.net.xpay.common.domain.LoginLog;
import com.net.xpay.common.manager.LoginLogManager;
import com.net.common.manager.AbstractManager;
import com.net.xpay.core.model.LoginLogSearchModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
@ReadTransactional
public class LoginLogManagerImpl extends AbstractManager<LoginLog> implements LoginLogManager{

    @Autowired
    private LoginLogMapper mapper;


    @Override
    protected BasicMapper<Long, LoginLog> getMapper() {
        return mapper;
    }

    @Override
    public List<LoginLog> search(LoginLogSearchModel loginLogSearchModel) {
        Preconditions.checkArgument(loginLogSearchModel != null);
        Page page = new Page(loginLogSearchModel);
        page.addOrder("id", "desc");
        return nonEmptyList(mapper.search(loginLogSearchModel, page));
    }

    @Override
    public Long searchCount(LoginLogSearchModel loginLogSearchModel) {
        Preconditions.checkArgument(loginLogSearchModel != null);
        return mapper.searchCount(loginLogSearchModel);
    }
}
